package com.esiran.payadmin.controller;

import com.esiran.payadmin.entity.Resp;
import com.esiran.payadmin.model.Menu;
import com.esiran.payadmin.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/admin/system/menu")
public class MenuController {

    private final MenuService menuService;
    @Autowired
    public MenuController(MenuService menuService) {
        this.menuService = menuService;
    }

    @GetMapping
    public String index() {
        List<Menu> menus = menuService.selectList(null);
        return "admin/system/menu";
    }
    @GetMapping("/create")
    public String create() {
        return "admin/system/menu_create";
    }
    @ResponseBody()
    @PostMapping("/create")
    public Resp<Void> createForm(Menu menu){
        menuService.create(menu);
        return Resp.empty();
    }
    @GetMapping("/{menuId}")
    public String index(@PathVariable String menuId) {
        return "admin/system/menu";
    }
    @PostMapping("/{menuId}")
    @ResponseBody
    public Resp<Void> update(@PathVariable String menuId){
        return Resp.empty();
    }
    @GetMapping("/del")
    @ResponseBody
    public Resp<Void> del(@RequestParam String menuId) {
        return Resp.empty();
    }
}
